$(function () {
    var uid = getQueryString("uid"),
        aid = getQueryString("aid");
    var referer = document.referer;
    var platform = navigator.platform;
    var device = "";
    //检测平台
    if (isAppleMobileDevice()) {
        device = "iphone";
    } else {
        device = "android";
    }

    var domain = window.location.hostname;
    //在微信打开
    wx.config({
        debug: false,
        appId: "",
        timestamp: "",
        nonceStr: "",
        signature: "",
        jsApiList: [
            "onMenuShareTimeline", "onMenuShareAppMessage", "onMenuShareQQ", "onMenuShareWeibo", "getNetworkType"  // 所有要调用的 API 都要加到这个列表中
        ]
    });
    wx.error(function (b) {
    });
    setTimeout(function () {
        wx.ready(function () {
            //用户打开页面十秒后再入库
            $.get("./deduction.php", {platform: platform, uid: uid, aid: aid, domain: domain, device : device}, function (data) {
                //alert(data);
            })
        })
    }, 10000);
});

function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}
//判断苹果函数
function isAppleMobileDevice() {
    return (/iphone|ipod|ipad|Macintosh/i.test(navigator.userAgent.toLowerCase()));
}

